#include<iostream>
#include<map>

using namespace std;

int weight[17]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
map<int,char> m={
	{0,'1'},{1,'0'},{2,'X'},{3,'9'},{4,'8'},{5,'7'},{6,'6'},
	{7,'5'},{8,'4'},{9,'3'},{10,'2'}
};

int main(){
	freopen("input.txt","r",stdin);
	int n;
	cin>>n;
	string s;
	int sum=0;
	int count=0;
	while(n--){
		cin>>s;
		sum=0;
		for(int i=0;i<18;i++){
			
			if(i<17){
				sum+=weight[i]*(s[i]-'0');
			}
			if(i==17){
				sum%=11;
				if(m[sum]!=s[i]){
					cout<<s<<endl;
					count++;
				}

			}
		}
		
	}
	if(!count){
		cout<<"All passed"<<endl;
	}
	return 0;
}